--守心拒外
local shouxingjuwai = fk.CreateSkill {
    name = "mcdh_shouxingjuwai",
    tags = {Skill.Compulsory}
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

shouxingjuwai:addEffect(fk.TargetConfirming,{
    can_trigger = function(self, event, target, player, data)
        if  player:hasSkill(self) and target == player  and data.from ~= player then
            local room = player.room
            local from = data.from
            local  cards = lib.getPublicCards(from)
            table.insertTableIfNeed(cards,lib.getPublicCards(player))
            return #table.filter(cards,function(id)
                local card = Fk:getCardById(id)
                return card.type == data.card.type
            end) == 0
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local from = data.from
        local  cards = lib.askForPublicCard(room,from,from,1,1,self.name,true,"#mcdh_shouxingjuwai-public:::"..data.card:getTypeString(),".|.|.|.|.|"..data.card:getTypeString(),false)
        if #cards == 0  then
            for _, p in ipairs(data.use.tos) do
                data:cancelTarget(p)
            end
        end
        lib.askForPublicCard(room,from,player,1,1,self.name,false,"e",".",false)
    end
})


Fk:loadTranslationTable {
    ["mcdh_shouxingjuwai"] = "守心拒外",
    [":mcdh_shouxingjuwai"] = "锁定技,当你成为其他角色使用牌的目标时，若你与其均没有与此牌类型相同的明置牌，其选择一项：1.明置一张与此牌类别相同的牌；2.取消此牌所有目标。选择结束后，其明置你一张牌。",
    ["#mcdh_shouxingjuwai-public"] = "守心拒外:明置一张 %arg ,否则取消此牌所有目标",
}

return shouxingjuwai